public class IsAlienSorted {

    public boolean getSorted(String[] worlds,String zidian){
        int[] index=new int[26];
        for (int i = 0; i < zidian.length(); i++) {
            index[zidian.charAt(i)-'a']=i;
        }
        for (int i = 1; i < worlds.length ; i++) {
            boolean isval=false;
            for (int j = 0; j < worlds[i-1].length()&&j<worlds[i].length(); j++) {
                int a=index[worlds[i].charAt(j)-'a'];
                int b=index[worlds[i-1].charAt(j)-'a'];
                if(a>b){
                    isval=true;
                    break;
                }
                if(a<b){
                    return false;
                }
            }
            if(!isval){
                if(worlds[i].length()<worlds[i-1].length()){
                    return false;
                }
            }
        }
        return true;
    }
}
